<template>
  <div>
    <template>
      <Tabs v-model="tabIndex" @on-click="changeTab" v-if="tabShow">
        <TabPane label="下级" name="tab1">
          <grid-level-info ref="gridLevel" :companyInfo="companyInfo" :choiceInfo="choiceInfo"></grid-level-info>
        </TabPane>
        <TabPane label="场所" name="tab2" v-if="choiceInfo.grade==='6'">
          <!--        <place-info :choiceInfo="choiceInfo"></place-info>-->
          <merchant ref="child" :pickInfo="choiceInfo"></merchant>
        </TabPane>
        <TabPane label="社会组织" name="tab3" v-if="choiceInfo.grade==='6'">
          <society ref="society" :pickInfo="choiceInfo"></society>
        </TabPane>
        <TabPane label="物件" name="tab4" v-if="choiceInfo.grade==='6'">
          <substance ref="substance" :pickInfo="choiceInfo"></substance>
        </TabPane>
        <TabPane label="添加管理人员" name="tab5" v-if="choiceInfo.grade === '5.5' || choiceInfo.grade === '6' ||  choiceInfo.grade === '7'">
          <manager ref="manager" :pickInfo="choiceInfo"></manager>
        </TabPane>
        <TabPane label="综合服务设施" name="tab6" v-if="choiceInfo.grade==='6'">
          <community-zhfwss ref="zhfwss" :pickInfo="choiceInfo"></community-zhfwss>
        </TabPane>
<!--        <TabPane label="党组织管理" name="tab7" v-if="choiceInfo.grade==='6'">-->
<!--          <DangZuZhiGuanLi ref="dzzgl" :companyInfo="companyInfo" :choiceInfo="choiceInfo"></DangZuZhiGuanLi>-->
<!--        </TabPane>-->
      </Tabs>
    </template>
  </div>
</template>

<script>
import GridLevelInfo from '../grid-level-info'
// import DangZuZhiGuanLi from '../dangzuzhiguanli'
import PlaceInfo from '../place-info'
import Merchant from '../../../xian-page/grid-maintain-new/components/merchant'
import Society from '../../../xian-page/grid-maintain-new/components/society'
import Substance from '../../../xian-page/grid-maintain-new/components/substance'
import Manager from '../../../xian-page/grid-maintain-new/components/manager'
import CommunityZhfwss from '../community-zhfwss'
export default {
  name: 'tableInfo',
  props: {
    choiceInfo: {
      type: Object
    },
    companyInfo: {
      type: Object
    }
  },
  components: {
    // DangZuZhiGuanLi,
    CommunityZhfwss, Manager, Substance, Society, Merchant, PlaceInfo, GridLevelInfo },
  data () {
    return {
      tabIndex: 0,
      tabShow: true
    }
  },
  methods: {
    changeTab (e) {
      console.log('choiceInfo', this.choiceInfo)
      console.log('companyInfo', this.companyInfo)
      if (e === 'tab1') {
        this.$refs.gridLevel.findGridLevelList()
      } else if (e === 'tab2') {
        this.$refs.child.init()
      } else if (e === 'tab3') {
        this.$refs.society.init()
      } else if (e === 'tab4') {
        this.$refs.substance.init()
      } else if (e === 'tab5') {
        this.$refs.manager.init()
      } else if (e === 'tab6') {
        this.$refs.zhfwss.init()
      }
      // else if (e === 'tab7') {
      //   this.$refs.dzzgl.init()
      // }
    },
    reloadTab () {
      this.tabShow = false
      this.$nextTick(() => {
        this.tabShow = true
        this.tabIndex = 0
      })
    }
  },
  watch: {
    'choiceInfo.id': function (newV, oldV) {
      if (newV !== oldV) {
        try {
          this.reloadTab()
        } catch (e) {
          // console.log('choiceInfo.id', e)
        }
      }
    }
  }
}
</script>

<style scoped>
</style>
